package com.ym.pms.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ym.pms.model.Listoffees;
import com.ym.pms.service.ListoffeesServices;
import com.ym.pms.utils.JSONResult;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ming
 * @since 2020-12-23
 */
@RestController
@Api(tags = "缴费接口")
@RequestMapping("/listoffees")
public class ListoffeesController {
    @Autowired
    ListoffeesServices listoffeesServices;

    @ApiOperation("获取指定用户的全部缴费单")
    @GetMapping("/{id}")
    public JSONResult getListoffees(@ApiParam("用户id")@PathVariable("id") Integer id,Integer pageNum,Integer pageSize){
        Page<Listoffees> page = new Page<>(pageNum, pageSize);
        listoffeesServices.findAll(id,page);
        return JSONResult.ok(page);
    }

    @ApiOperation("设置状态为已缴费")
    @GetMapping("/pay/{id}")
    public JSONResult pay(@ApiParam("缴费单id")@PathVariable("id") Integer id){
        listoffeesServices.pay(id);
        return JSONResult.ok();
    }

    @ApiOperation(value = "手动生成签合同当月缴费单",notes = "签合同当月请调用此接口生成缴费单")
    @GetMapping("/generateFee/{id}")
    public JSONResult generateFee(@ApiParam("合同id")@PathVariable("id") Integer id){
        listoffeesServices.generateFee(id);
        return JSONResult.ok();
    }
}

